/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2023-01-13
 * Time: 9:54
 */
public class Test {
    public static void main(String[] args) {

    }

    public static void insertSort(int[] array) {
        int tmp = 0;
        for (int i = 0; i < array.length; i++) {
            for (int j = i - 1; j >= 0; j--) {
                tmp = array[i];
                if (array[j] > tmp) {
                    array[j + 1] = array[j];
                } else {
                    array[j + 1] = tmp;
                    break;
                }
            }
        }
    }
    public static void shell(int[] array,int gap){
        int tmp1 = 0;
        for (int i = gap; i < array.length; i++) {
            for (int j = i - gap; j >= 0; j-=gap) {
                tmp1 = array[i];
                if (array[j] > tmp1) {
                    array[j + gap] = array[j];
                } else {
                    array[j + gap] = tmp1;
                    break;
                }
            }
        }
    }
    public static void selectSort(int[] array) {
        for (int i = 0; i < array.length; i++) {
            int min = i;
            int j = i + 1;
            for (; j < array.length; j++) {
                if (array[j] < array[min]) {
                    min = j;
                }
            }
            if (min != i) {
                int tmp = array[i];
                array[i] = array[min];
                array[min] = tmp;
            }
        }
    }
}
